package com.cacshanghai.cac_oa_client.ui;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;

import com.cacshanghai.cac_oa_client.R;
import com.cacshanghai.cac_oa_client.widget.HorizontalListView;
import com.cacshanghai.cac_oa_client.adapter.HorizontalListViewAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by geyh on 2016/5/24.
 */
public class MeetingFragment extends HomePageBaseFragment {

    private HorizontalListView hlv_meeting;
    private HorizontalListViewAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_meeting, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        setTitle(R.string.my_meeting);
        setTitleOnClickToPage(MeetingActivity.class);

        List<String> meetingList = new ArrayList<>();
        hlv_meeting = (HorizontalListView) getView().findViewById(R.id.hlv_meeting);
        adapter = new HorizontalListViewAdapter(getActivity().getApplicationContext(), meetingList);
        hlv_meeting.setAdapter(adapter);
        hlv_meeting.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getActivity(), MeetingFormActivity.class);
                startActivity(intent);
            }
        });
        hlv_meeting.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle("是否取消会议").setMessage("中会议室\n09:30~10:30\n主题：urs文档评审\n备注：无")
                        .setPositiveButton("确认", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        }).create().show();
                return false;
            }
        });

    }
}
